package cn.dmp.tags

import org.apache.spark.sql.Row

object Tags4Device extends Tags{
    /**
      * 行数据 -》 标签数据
      *
      * @param args
      * @return
      */
    override def makeTags(args: Any*): Map[String, Int] = {

        var tags = Map[String, Int]()

        val row = args(0).asInstanceOf[Row]

        // 设备
        val ispname = row.getAs[String]("ispname")
        val nwname = row.getAs[String]("networkmannername")
        val client = row.getAs[Int]("client")

        ispname match {
            case "移动" => tags += "D00030001" -> 1
            case "联通" => tags += "D00030002" -> 1
            case "电信" => tags += "D00030003" -> 1
            case _ => tags += "D00030004" -> 1
        }


        nwname.toUpperCase match {
            case "WIFI" => tags += "D00020001" -> 1
            case "4G" => tags += "D00020002" -> 1
            case "3G" => tags += "D00020003" -> 1
            case "2G" => tags += "D00020004" -> 1
            case _ => tags += "D00020005" -> 1
        }

        client match {
            case 1 => tags += "D00010001" -> 1
            case 2 => tags += "D00010002" -> 1
            case 3 => tags += "D00010003" -> 1
            case _ => tags += "D00010004" -> 1
        }

        tags
    }
}
